/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.trick.admin.binding;

import javafx.beans.binding.BooleanBinding;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

/**
 *
 * @author takahara
 */
public class UpdateChannelButtonBinding extends BooleanBinding {

    private TextField nameTextField;
    private TextArea descriptionTextArea;
    private TextArea contentsTextArea;

    public UpdateChannelButtonBinding(TextField nameTextField, TextArea descriptionTextArea, TextArea contentsTextArea) {
        this.nameTextField = nameTextField;
        this.descriptionTextArea = descriptionTextArea;
        this.contentsTextArea = contentsTextArea;

        super.bind(this.nameTextField.textProperty());
        super.bind(this.descriptionTextArea.textProperty());
        super.bind(this.contentsTextArea.textProperty());
    }

    @Override
    protected boolean computeValue() {

        String name = nameTextField.getText().trim();
        if(name == null) return true;
        if(name.equals("")) return true;

        String description = descriptionTextArea.getText().trim();
        if(description == null) return true;
        if(description.equals("")) return true;

        String contents = contentsTextArea.getText().trim();
        if(contents == null) return true;
        if(contents.equals("")) return true;

        return false;
    }

}
